<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <canvas id="canvas" width="800"
  height="800"></canvas>

  <script>
    const canvasDom = document.getElementById('canvas');
    const drawer = canvasDom.getContext('2d');
    
    // 绘制
    drawer.beginPath();
    drawer.moveTo(30,30);
    drawer.lineTo(320, 320);
    drawer.stroke(); // 显示路径
    drawer.closePath()

    // 绘制三角形
    drawer.beginPath();
    drawer.moveTo(200, 100);
    drawer.lineTo(250, 150);
    drawer.lineTo(250, 100);
    drawer.lineTo(200, 100);
    drawer.fill();
    drawer.closePath();

  </script>
</body>
</html>